package com.feiyang.ni;

import java.util.Random;

public class CodeUtil {
    private CodeUtil() {

    }
    public static String getCode() {
        String code = "";
        Random r = new Random();
        char[] ch = new char[62];
        for (int i = 0; i < ch.length; i++) {
            if (i < 10) {
                ch[i] = (char)(i + '0');
            }
            if (i >= 10 && i < 36) {
                ch[i] = (char) (i - 10 + 'A');
            }
            if (i >= 36 && i < 62) {
                ch[i] = (char) (i - 36 + 'a');
            }
        }
        for (int i = 0; i < 5; i++) {
            int index = r.nextInt(62);
            code = code + ch[index];
        }
        return code;
    }
}
